#coding: utf-8
#xfby_2016.1.29
import re 
from collections import defaultdict
i=0
result = defaultdict()
xtable = {
    "amazon.cn" : re.compile("dp/[A-Z0-9]+"),
    "escentual.com" : re.compile(".+"),
    "luisaviaroma.com" : re.compile("index.aspx.*"),
    "wiggle.cn" :  re.compile(".+"),
    "jomashop.com" : re.compile("\\.html"),
    "amazon.ca" : re.compile("product/[A-Z0-9]+"),
    "6pm.com" : re.compile("product/\\d+"),
    "1.macys.com" : re.compile("product/.+"),
    "finishline.com" : re.compile("product\\?.+"),
    "amazon.co.uk" : re.compile("(?:dp|product)/[A-Z0-9]+"),
    "drugstore.com" : re.compile(".catid+"),
    "carters.com" : re.compile(".carters+"),
    "sears.com" : re.compile(".+"),
    "amazon.co.jp" : re.compile("(?:dp|product)/[A-Z0-9]+"),
    "store.nba.com" : re.compile(".+"),
    "lookfantastic.com" : re.compile(".list+|(?:[0-9]+.html)+"),
    "rei.com" : re.compile("product/[0-9]+"),
    "newbalance.com.cn" : re.compile("[index.]+"),
    "swarovski.com.cn" : re.compile(".product/+"),
    "mdreams.com" : re.compile(".+"),
    "converse.com.cn" : re.compile(".item+"),
    "microsoftstore.com.cn" : re.compile("/p/+"),
    "godiva.com" : re.compile(".[0-9]+"),
    "kiehls.com.br" : re.compile(".+"),
    "disneystore.com" : re.compile("./[0-9]+"),
    "groupon.com" : re.compile("deals/+"),
    "footlocker.com" : re.compile("product/+"),
    "campsaver.com" : re.compile(".+"),
    "joesnewbalanceoutlet.com" : re.compile(b".?style+"),
    "tiffany.cn" : re.compile(".+"),
    "amazon.fr" : re.compile("(?:dp|product)/[A-Z0-9]+"),
    "rakuten.com" : re.compile("prod/+"),
    "wn.pos.baidu.com" : re.compile(".+")
    }
file = open(r'C:\Users\john\Desktop\re\tcp-url-2016-01-05-12-test.log','r')

try:
    k = 0
    for line in file:
        print(line.strip())
        print(0)
        a = line.split(' : ')
#        *a,f, = line.split(' ',5)
        print(a)
        print(1)
        '''
        host,path = f.split('/',1)
        print(host)
        print(path)
        pass
        if host in xtable:
            k+=1
            try:
                if xtable[host].search(path):
                    result[host]=i+1
            except ValueError as e:
                pass
        '''
except ValueError as e:
    print(e)
    pass
    
print(result,k)

print(result,k)

        
